﻿using System;

namespace IupNET
{
    public class Valuator:Control
    {
        public Valuator()
            : base(Iupc.Val(null))
        {
            
        }

        public bool CanFocus
        {
            get
            {
                return GetAttribute("CANFOCUS") == "YES";
            }
            set
            {
                SetAttribute("CANFOCUS", value ? "YES" : "NO");
            }
        }

        public bool Inverted
        {
            get
            {
                return GetAttribute("INVERTED") == "YES";
            }
            set
            {
                SetAttribute("INVERTED", value ? "YES" : "NO");
            }
        }


        public double Max
        {
            get
            {
                return (double)Iupc.GetFloat(cobject, "MAX");
            }
            set
            {
                SetAttribute("MAX", Convert.RealToString(value));
            }
        }

        public double Min
        {
            get
            {
                return (double)Iupc.GetFloat(cobject, "MIN");
            }
            set
            {
                SetAttribute("MIN", Convert.RealToString(value));
            }
        }

        public double PageStep
        {
            get
            {
                return (double)Iupc.GetFloat(cobject, "PAGESTEP");
            }
            set
            {
                SetAttribute("PAGESTEP", Convert.RealToString(value));
            }
        }

        public int ShowTicks
        {
            get
            {
                return Convert.StringToInt(GetAttribute("SHOWTICKS"));
            }
            set
            {
                SetAttribute("SHOWTICKS", value.ToString());
            }
        }

        public double Step
        {
            get
            {
                return (double)Iupc.GetFloat(cobject, "STEP");
            }
            set
            {
                SetAttribute("STEP", Convert.RealToString(value));
            }
        }

        public TickPos TickPos
        {
            get
            {
                return Convert.StringToTickPos(GetAttribute("TICKPOS"));
            }
            set
            {
                SetAttribute("TICKPOS", Convert.TickPosToString(value));
            }
        }

        public bool Horizontal
        {
            get
            {
                return GetAttribute("TYPE") == "HORIZONTAL";
            }
            set
            {
                SetAttribute("TYPE", value ? "HORIZONTAL" : "VERTICAL");
            }
        }


        public new double Value
        {
            get
            {
                return Convert.StringToReal(GetAttribute("VALUE"));
            }
            set
            {
                SetAttribute("VALUE", Convert.RealToString(value));
            }
        }

        public EventCallback ChangeValueCB
        {
            get
            {
                return CBHandler.Fetch("CHANGEVALUE_CB");
            }
            set
            {
                CBHandler.Set("CHANGEVALUE_CB", value);
            }
        }
    

    
    }
}
